
package com.ymx.sdk.animator;

import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;

public  class animatorUtils {

    public static ObjectAnimator translateY(Object view, float fromPosition,float toPosition, long duration,
            TimeInterpolator interpolator) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationY", fromPosition, toPosition);
        animator.setDuration(duration);
        if (interpolator != null) {
            animator.setInterpolator(interpolator);
        }
        return animator;
    }
  
    public static ObjectAnimator translateX(Object view, float fromPosition,float toPosition, long duration,
            TimeInterpolator interpolator) {
        ObjectAnimator animator = ObjectAnimator.ofFloat(view, "translationX", fromPosition, toPosition);
        animator.setDuration(duration);
        if (interpolator != null) {
            animator.setInterpolator(interpolator);
        }
        return animator;
    }

    public static ObjectAnimator alpha(Object view, float fromAlpha,float toAlpha, long duration,
                                            TimeInterpolator interpolator) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(view, "alpha", fromAlpha, toAlpha);
        anim.setDuration(duration);
        if (interpolator != null) {
            anim.setInterpolator(interpolator);
        }
        return anim;
    }

    public static ObjectAnimator scaleX(Object view, float fromScale,float toScale, long duration,
                                       TimeInterpolator interpolator) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(view, "scaleX", fromScale, toScale);
        anim.setDuration(duration);
        if (interpolator != null) {
            anim.setInterpolator(interpolator);
        }
        return anim;
    }

    public static ObjectAnimator scaleY(Object view, float fromScale,float toScale, long duration,
                                        TimeInterpolator interpolator) {
        ObjectAnimator anim = ObjectAnimator.ofFloat(view, "scaleY", fromScale, toScale);
        anim.setDuration(duration);
        if (interpolator != null) {
            anim.setInterpolator(interpolator);
        }
        return anim;
    }
}
